import request from '@/api/request';
export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data,
  });
}
export function register(data) {
  return request({
    url: '/register',
    method: 'post',
    data,
  });
}
export function getUsers() {
  return request({
    url: '/users',
    method: 'get',
  });
}
export function getUser() {
  return request({
    url: `/user`,
    method: 'get',
  });
}
export function getUserById(id) {
  return request({
    url: `/user/${id}`,
    method: 'get',
  });
}
export function updateUser(id, data) {
  return request({
    url: `/user/${id}`,
    method: 'put',
    data,
  });
}
export function createUser(data) {
  return request({
    url: `/user`,
    method: 'post',
    data,
  });
}
export function deleteUser(id) {
  return request({
    url: `/user/${id}`,
    method: 'delete',
  });
}
export function updatePassword(id, data) {
  return request({
    url: `/user_updatePassword/${id}`,
    method: 'post',
    data,
  });
}
export function resetPassword(data) {
  return request({
    url: `user_resetPassword`,
    method: 'post',
    data,
  });
}
export function getUserInfo(token) {
  return new Promise((resolve, reject) => {
    let data = {
      success: true,
      data: {
        user: {
          id: 1,
          avatar: 'https://img.soogif.com/oMoxAAWRVXZvHB9SkuMbWrh89IrB4Ogj.gif',
          name: 'R2D2',
          roles: ['admin'],
        },
      },
    };
    resolve(data);
  });
}
